<?php $templates = getContentTemplates($_REQUEST['site']); ?>
<div class="menu_top">
	<input type="hidden" name="action" value="new_template">
	<input type="submit" value="Add new template" class="buttons" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/new.gif'); border:1px solid #DDDDDD;" />&nbsp;&nbsp;
	Title:&nbsp;&nbsp;<input name="title" type="text" value="" maxlength="99">
	<input type="submit" value="Save" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/save.gif'); border:1px solid #DDDDDD; height:20px;" class="buttons">
</div>
<div class="menu_list">
<table id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
	<tr>
		<th nowrap="nowrap">#&nbsp;ID&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Title&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Area&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Access Level&nbsp;&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Active&nbsp;&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Edit&nbsp;&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Delete</th>
	</tr>
	<?php 
	if($templates):
	foreach($templates as $template)
	{
	?>
	<tr class="items">
		<td nowrap="nowrap">#&nbsp;<input type="hidden" name="temp_id[]" value="<?php echo $template['id']; ?>" /><?php echo $template['id']; ?></td>
		<td nowrap="nowrap"><input class="inp_txt" name="temp_title[]" type="text" value="<?php echo $template['title']; ?>" maxlength="90" /></td>
		<td nowrap="nowrap">
			<select name="site_area[]" onchange="submit();"  >
				<option value="0" <?php if ($template['site_area'] == 0){echo 'selected="selected"'; }?> >Content</option>
				<option value="1" <?php if ($template['site_area'] == 1){echo 'selected="selected"'; }?> >Header</option>
				<option value="2" <?php if ($template['site_area'] == 2){echo 'selected="selected"'; }?> >Footer</option>
				<option value="3" <?php if ($template['site_area'] == 3){echo 'selected="selected"'; }?> >Col Left</option>
				<option value="4" <?php if ($template['site_area'] == 4){echo 'selected="selected"'; }?> >Col Right</option>
			</select>
		</td>
		<td nowrap="nowrap">
			<?php 
				if($template['access'] == 0)
				{ $bg = 'access_0.gif'; }
				else
				{ $bg = 'access_1.gif'; }
			?>
			<select name="access[]" onchange="submit();" style="background:transparent url(../images/system/<?php echo $bg; ?>) no-repeat scroll left top; padding-left:18px;" >
				<?php
				foreach($groups as $group)
				{
					if($template['access'] == $group['id'])
					{ echo '<option value="'.$group['id'].'" selected>'.$group['name'].'</option>'; }
					else
					{ echo '<option value="'.$group['id'].'">'.$group['name'].'</option>'; }
				}
				?>
			</select>
		</td>
		<td nowrap="nowrap">
			<?php if($template['active'] == 0): ?>
			<img src="../images/system/active_<?php echo $template['active']; ?>_25.gif" alt="activate" onmousedown="document.getElementById('activate').value='<?php echo $template['id']; ?>';" onmouseup="edit_form.submit();" />
			<?php else: ?>
			<img src="../images/system/active_<?php echo $template['active']; ?>_25.gif" alt="deactivate" onmousedown="document.getElementById('deactivate').value='<?php echo $template['id']; ?>';" onmouseup="edit_form.submit();" />
			<?php endif; ?>
		</td>
		<td nowrap="nowrap">
			<a href="?con=<?php echo $_REQUEST['con']; ?>&item=<?php echo $template['id']; ?>"><img src="../images/system/templ.gif" border="0" /></a>&nbsp;
		</td>
		<td nowrap="nowrap"><input class="inp_image" type="image" name="delete_template" src="../images/system/trash_25.gif" value="0" onclick="this.value='<?php echo $template['id']; ?>'; edit_form.submit();" /></td>
	</tr>
	<?php
	}
	?>
</table>
<input type="hidden" id="activate" name="activate" value="0" />
<input type="hidden" id="deactivate" name="deactivate" value="0" />
</div>
<?php endif; ?>